package net.neiquan.neiquandemowithkf.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.neiquan.neiquandemowithkf.R;
import net.neiquan.neiquandemowithkf.entity.MyUser;
import net.neiquanlib.base.MyBaseAdapterListView;
import net.neiquanlib.utils.ImageUtils;
import net.neiquanlib.widget.RoundImageView;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * 作者 ： hjb
 * 时间 ： 2016/7/25.
 */

public class PinyinDemoAdapter extends MyBaseAdapterListView {
    public PinyinDemoAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_pinyin_demo, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        MyUser myUser = (MyUser) data.get(position);
        ImageUtils.loadPicNet(myUser.getHeadUrl(), viewHolder.mHeadImg);
        viewHolder.mNickName.setText(myUser.getNickName());
        return convertView;
    }

    static class ViewHolder {
        @InjectView(R.id.head_img)
        RoundImageView mHeadImg;
        @InjectView(R.id.nickName)
        TextView mNickName;

        ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }
}
